<?php
/**
 * 文章分类控制器
 * @author silenus
 *
 */
class m_acategory extends spModel {
	public $pk = 'acategory_id';
	public $table = 'acategory';
	/**
	 * 与文章是一对多关系
	 * 与自身是一对多关系
	 */
	var $linker = array (
			/**
			 * 与文章
			 */
			array (
					'type' => 'hasmany', // 多对多关联
					'map' => 'article', // 关联的标识
					'mapkey' => 'acategory_id', // 关联的字段
					'fclass' => 'm_article', // 对应表的数据类
					'fkey' => 'acategory_id', // 对应表的关联字段
// 					'field' => 'article_id,author,title' ,
					'sort' => 'post_time DESC',
					'enabled' => true 
			),
			
			/**
			 * 与自身,父分类
			 */
			array(
					'type' => 'hasone',
					'map' => 'parent',
					'mapkey' => 'parent_id',
					'fclass' => 'm_acategory',
					'fkey' => 'acategory_id',
					'field' => 'name,acategory_id',
					'enabled' => true
			),
			
			/**
			 * 与自身,子分类
			 */
			array(
					'type' => 'hasmany',		
					'map' => 'children',
					'mapkey' => 'acategory_id',
					'fclass' => 'm_acategory',
					'fkey' => 'parent_id',
					'field' => 'name,acategory_id', // acategory_id 看是否删除
// 					'sort' => 'sort_order',
					enabled =>true
			),
			
			
			
			
// 			array (
// 					'type' => 'hasmany', // 一对多关联
// 					'map' => 'member', // 关联的标识
// 					'mapkey' => 'user_id',
// 					'fclass' => 'guestbook',
// 					'fkey' => 'user_id',
// 					'enabled' => true 
// 			) 
	);
	var $verifier = array(
			'rules' => array(
					'acategory_name' => array(
					),
					'parent_id' => array(
					),
					'sort_order' => array(
					),
					'code' => array(
					),
			));

	public function mod_edit($acategory_id,$content){
			$this->update("`acategory` = {$acategory_id}",$content);
	}
}